﻿<%@ page language="java" import="com.newcrm.config.Const,com.newcrm.config.Config,com.newcrm.util.Util,com.newcrm.bean.*,java.util.List,java.util.Map" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%
  User user = (User) session.getAttribute("user");
  Map<Integer, CompanyInfo> companys = (Map<Integer, CompanyInfo>) application.getAttribute(Const.APPLICATION_COMPANYS);
  CompanyInfo companyInfo = companys.get(Integer.valueOf(user.companyId));
  List<User> users = companyInfo.users;
%>
    <option value="<%=user.userId%>" selected="selected" t="user">我的客户</option>
<%
  String groupName = null;
  for (User u : users) {
    if (u.userId.equals(user.userId)) {
      continue;
    }
    if (!companyInfo.isGroupAdmin(user, u.groupId)) {
      continue;
    }
    String gn = companyInfo.getGroupName(u);
    if (groupName == null) {
      if (gn != null) {
        groupName = gn;  %>
  <optgroup label="<%=Util.HTMLEncode(groupName)%>">
  <%
      }
    } else {
      if (!groupName.equals(gn)) {
      groupName = gn; %>
  </optgroup>
  <optgroup label="<%=Util.HTMLEncode(groupName)%>">
    <%
      }
    }
    %>
    <option value="<%=u.userId%>" t="user"><%=Util.HTMLEncode(u.name)%>的客户</option>
  <%
  }
  if (groupName != null && groupName.length() > 0) { %>
  </optgroup>
  <%}%>